<?php

if(isset($_GET['trade_id'])){

require('settings.php');
require('dbConn.php');

	$arr['subtrades'] = array();
	$arr['subtradestext'] = array();
	
	/*Change By Vyas Ishan 16 May 2013 Task2
	$sql = "SELECT trades_to_trades.trade_id, trades.trade FROM trades_to_trades 
			LEFT JOIN trades ON trades_to_trades.trade_id = trades.id
			WHERE parent_id = '".mysql_real_escape_string($_GET['trade_id'])."'";
	*/		
	$sql = "SELECT trades_to_trades.trade_id, trades.trade FROM trades_to_trades 
			JOIN trades ON trades_to_trades.trade_id = trades.id
			WHERE parent_id = '".mysql_real_escape_string($_GET['trade_id'])."'";		
			
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	while($rs=mysql_fetch_assoc($query)){
	
	$arr['subtrades'][] = $rs['trade_id'];
	$arr['subtradestext'][] = $rs['trade'];
	
	}

echo json_encode($arr);


}

?>